﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Job.Logic.Common;
using Job.Logic.BaseContent;
using Job.Entity;
using System.Text;
using Job.Web.Framework;

namespace Job.Web.AdminWeb
{
    public partial class AdminLogin :BasePage
    {
        int logout = myR["logout"].IntValue;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                if (logout == 1)
                {
                    MySession session = new MySession();
                    session.RemoveAdminUserFromSession();
                }

                lblMessage.Visible = false;
                lblMessage.Text = "用户名/密码错误，请重新输入！";
            }
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            lblMessage.Visible = false;
            CommonLogic clogic = new CommonLogic();
            if (clogic.Login(txtUsername.Text.Trim(), txtPassword.Text.Trim()))
            {
                AdminUserLogic uLogic = new AdminUserLogic();
                JobUser user = uLogic.GetDetailByLogin(txtUsername.Text.Trim());
                MySession session = new MySession();
                session.AddAdminUser2Session(user);

                Response.Redirect("Index.aspx");
            }
            else
            {
                lblMessage.Visible = true;
            }

        }
    }
}
